package com.zelin.manager.web;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import com.alibaba.dubbo.config.annotation.Reference;
import com.zelin.content.service.ContentCategoryService;
import com.zelin.entity.ContentCategoryEntity;
import com.zelin.utils.PageUtils;
import com.zelin.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;





/**
 * 内容分类
 *
 * @author WF
 * @email 2568783935@qq.com
 * @date 2021-07-23 21:10:35
 */
@RestController
@RequestMapping("/contentcategory")
public class ContentCategoryController {
    @Reference(timeout = 5000)
    private ContentCategoryService contentCategoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("manager:contentcategory:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = contentCategoryService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("manager:contentcategory:info")
    public R info(@PathVariable("id") Long id){
		ContentCategoryEntity contentCategory = contentCategoryService.getById(id);

        return R.ok().put("contentCategory", contentCategory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("manager:contentcategory:save")
    public R save(@RequestBody ContentCategoryEntity contentCategory){
		contentCategoryService.save(contentCategory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("manager:contentcategory:update")
    public R update(@RequestBody ContentCategoryEntity contentCategory){
		contentCategoryService.updateById(contentCategory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("manager:contentcategory:delete")
    public R delete(@RequestBody Long[] ids){
		contentCategoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
